#!/usr/bin/python

class RuleNode:
	def __init__(self,i,l,h):
		self._id = i
		self._label = l
		self._head = h

class SimpleRule:
	def __init__(self):
		self._lhs = None
		self._rhs = []

	def addRhs(self,r):
		self._rhs.append(r.strip())

	def equals(self,r):
		return self.toString() == r.toString()

	def toString(self):
		return self._lhs+" -> "+" ".join(self._rhs)
	
class HeadedRule:
	def __init__(self):
		self._lhs = ""
		self._rhs = []
		self._prob = 0.0
	
	def addRhs(self,r):
		self._rhs.append(r)

	def toString(self):
		rstr = []
		for s in self._rhs:
			rstr.append(s._label+"("+s._head+")")
		return self._lhs._label+"("+self._lhs._head+") -> " \
		 + " ".join(rstr)
